package controller

import (
	"fmt"
	"github.com/gofiber/fiber"
	"gowork/viewExamineNode/model"
	"gowork/viewExamineNode/service"
	"log"
)

type ViewController struct {
	viewService *service.ViewService
}

func (vc *ViewController)InsertRegionCheckNode(c *fiber.Ctx){

	vc.viewService = new(service.ViewService)

	var regionList []*model.Region
	if err := c.BodyParser(&regionList); err != nil {
		log.Fatal(err)
	}
	fmt.Println(regionList)

	res , err := vc.viewService.InsertRegionCheckNode(regionList)
	if err != nil{
		c.JSON(fiber.Map{
			"code": 500,
			"data": nil,
			"message": err.Error(),
		})
		return
	}

	c.JSON(fiber.Map{
		"code": res["code"],
		"data": nil,
		"message": res["message"],
	})
	return
}